<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <%@ include file="../../share/layoutIndex.jsp"%> 
  </head>
<body>
<form id="form1">
	<div style="margin-top: 10px; margin-right: 30px;">
		<input id="buttonId" type="hidden" value="" />
		<input id="moduleId" type="hidden" />
		<table class="form">
			<tr>
				<th class="formTitle">上级</th>
				<td class="formValue">
					<div id="parentId" type="selectTree" class="ui-select">
					</div>
				</td>
			</tr>
			<tr>
				<th class="formTitle">名称<font face="宋体">*</font></th>
				<td class="formValue">
					<input id="buttonName" type="text" class="form-control" placeholder="请输入名称" isvalid="yes" checkexpession="NotNull" />
				</td>
			</tr>
			<tr>
				<th class="formTitle">图标<font face="宋体">*</font></th>
				<td class="formValue">
					<input id="buttonIcon" type="text" class="form-control" placeholder="请输入图标" isvalid="yes" checkexpession="NotNull" />
				</td>
			</tr>
			<tr>
				<th class="formTitle">排序<font face="宋体">*</font></th>
				<td class="formValue">
					<input id="sortCode" type="text" class="form-control" placeholder="请输入排序" isvalid="yes" checkexpession="Num" />
				</td>
			</tr>
			<tr>
				<th class="formTitle">地址</th>
				<td class="formValue">
					<input id="actionAddress" type="text" class="form-control" />
				</td>
			</tr>
		</table>
	</div>
</form>
<script type="text/javascript">
    var parentId = request('parentId');
    var buttonId = request('buttonId');
    var moduleId = request('moduleId');
    $(function () {
        initControl();
    })
    var dataJson = top.Form.buttonJson;
    //初始化控件
    function initControl() {
        //上级
        $("#parentId").ComboBoxTree({
            url: "<%=basePath%>sysModuleButton/listToTreeJson.do",
            param: { moduleButtonJson: JSON.stringify(dataJson) },
            method: "post",
            description: "==请选择==",
            height: "150px"
        });
        if (!!buttonId) {
            $.each(dataJson, function (i) {
                var row = dataJson[i];
                if (row.buttonId == buttonId) {
                    $("#form1").SetWebControls(row);
                }
            });
        } else {
            $("#moduleId").val(moduleId);
            if (!!parentId) {
                $("#parentId").ComboBoxTreeSetValue(parentId);
            } else {
                $("#parentId").ComboBoxTreeSetValue(0);
            }
        }
    }
    //保存表单
    function AcceptClick(callback) {
        if (!$('#form1').Validform()) {
            return false;
        }
        var data = $("#form1").GetWebControls(buttonId);
        if (data["parentId"] == "") {
            data["parentId"] = 0;
        }
		if(data["buttonId"]==""){
			data["buttonId"]=new Date().getTime();
		}
        callback(data);
        dialogClose();
    }
</script>
</body>
</html>
